home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / swingall.jar / javax / swing / text / html / HTMLDocument$LeafIterator.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-07-15  |  2.0 KB  |  96 lines

  1. package javax.swing.text.html;
  2.  
  3. import javax.swing.text.AttributeSet;
  4. import javax.swing.text.Document;
  5. import javax.swing.text.Element;
  6. import javax.swing.text.ElementIterator;
  7.  
  8. class HTMLDocument$LeafIterator extends HTMLDocument.Iterator {
  9.    private int endOffset;
  10.    private HTML.Tag tag;
  11.    private ElementIterator pos;
  12.  
  13.    HTMLDocument$LeafIterator(HTML.Tag var1, Document var2) {
  14.       this.tag = var1;
  15.       this.pos = new ElementIterator(var2);
  16.       this.endOffset = 0;
  17.       this.next();
  18.    }
  19.  
  20.    public AttributeSet getAttributes() {
  21.       Element var1 = this.pos.current();
  22.       if (var1 != null) {
  23.          AttributeSet var2 = (AttributeSet)var1.getAttributes().getAttribute(this.tag);
  24.          return var2;
  25.       } else {
  26.          return null;
  27.       }
  28.    }
  29.  
  30.    public int getEndOffset() {
  31.       return this.endOffset;
  32.    }
  33.  
  34.    public int getStartOffset() {
  35.       Element var1 = this.pos.current();
  36.       return var1 != null ? var1.getStartOffset() : -1;
  37.    }
  38.  
  39.    public HTML.Tag getTag() {
  40.       return this.tag;
  41.    }
  42.  
  43.    public boolean isValid() {
  44.       return this.pos.current() != null;
  45.    }
  46.  
  47.    public void next() {
  48.       this.nextLeaf(this.pos);
  49.  
  50.       for(; this.isValid(); this.nextLeaf(this.pos)) {
  51.          Element var1 = this.pos.current();
  52.          if (var1.getStartOffset() >= this.endOffset) {
  53.             AttributeSet var2 = this.pos.current().getAttributes();
  54.             if (var2.isDefined(this.tag)) {
  55.                this.setEndOffset();
  56.                break;
  57.             }
  58.          }
  59.       }
  60.  
  61.    }
  62.  
  63.    void nextLeaf(ElementIterator var1) {
  64.       var1.next();
  65.  
  66.       while(var1.current() != null) {
  67.          Element var2 = var1.current();
  68.          if (var2.isLeaf()) {
  69.             break;
  70.          }
  71.  
  72.          var1.next();
  73.       }
  74.  
  75.    }
  76.  
  77.    void setEndOffset() {
  78.       AttributeSet var1 = this.getAttributes();
  79.       this.endOffset = this.pos.current().getEndOffset();
  80.       ElementIterator var2 = (ElementIterator)this.pos.clone();
  81.       this.nextLeaf(var2);
  82.  
  83.       while(var2.current() != null) {
  84.          Element var3 = var2.current();
  85.          AttributeSet var4 = (AttributeSet)var3.getAttributes().getAttribute(this.tag);
  86.          if (var4 == null || !var4.equals(var1)) {
  87.             break;
  88.          }
  89.  
  90.          this.endOffset = var3.getEndOffset();
  91.          this.nextLeaf(var2);
  92.       }
  93.  
  94.    }
  95. }
  96.